package com.lekang.le.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.lekang.common.annotation.Log;
import com.lekang.common.core.controller.BaseController;
import com.lekang.common.core.domain.AjaxResult;
import com.lekang.common.enums.BusinessType;
import com.lekang.le.domain.CaregiverBedBinding;
import com.lekang.le.service.ICaregiverBedBindingService;
import com.lekang.common.utils.poi.ExcelUtil;
import com.lekang.common.core.page.TableDataInfo;

/**
 * 护理员与床位中间Controller
 * 
 * @author szh
 * @date 2025-10-20
 */
@RestController
@RequestMapping("/le/caregiverBedBinding")
public class CaregiverBedBindingController extends BaseController
{
    @Autowired
    private ICaregiverBedBindingService caregiverBedBindingService;

    /**
     * 查询护理员与床位中间列表
     */
    @PreAuthorize("@ss.hasPermi('le:caregiverBedBinding:list')")
    @GetMapping("/list")
    public TableDataInfo list(CaregiverBedBinding caregiverBedBinding)
    {
        startPage();
        List<CaregiverBedBinding> list = caregiverBedBindingService.selectCaregiverBedBindingList(caregiverBedBinding);
        return getDataTable(list);
    }

    /**
     * 导出护理员与床位中间列表
     */
    @PreAuthorize("@ss.hasPermi('le:caregiverBedBinding:export')")
    @Log(title = "护理员与床位中间", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CaregiverBedBinding caregiverBedBinding)
    {
        List<CaregiverBedBinding> list = caregiverBedBindingService.selectCaregiverBedBindingList(caregiverBedBinding);
        ExcelUtil<CaregiverBedBinding> util = new ExcelUtil<CaregiverBedBinding>(CaregiverBedBinding.class);
        util.exportExcel(response, list, "护理员与床位中间数据");
    }

    /**
     * 获取护理员与床位中间详细信息
     */
    @PreAuthorize("@ss.hasPermi('le:caregiverBedBinding:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(caregiverBedBindingService.selectCaregiverBedBindingById(id));
    }

    /**
     * 新增护理员与床位中间
     */
    @PreAuthorize("@ss.hasPermi('le:caregiverBedBinding:add')")
    @Log(title = "护理员与床位中间", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CaregiverBedBinding caregiverBedBinding)
    {
        return toAjax(caregiverBedBindingService.insertCaregiverBedBinding(caregiverBedBinding));
    }

    /**
     * 修改护理员与床位中间
     */
    @PreAuthorize("@ss.hasPermi('le:caregiverBedBinding:edit')")
    @Log(title = "护理员与床位中间", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CaregiverBedBinding caregiverBedBinding)
    {
        return toAjax(caregiverBedBindingService.updateCaregiverBedBinding(caregiverBedBinding));
    }

    /**
     * 删除护理员与床位中间
     */
    @PreAuthorize("@ss.hasPermi('le:caregiverBedBinding:remove')")
    @Log(title = "护理员与床位中间", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(caregiverBedBindingService.deleteCaregiverBedBindingByIds(ids));
    }
}
